package com.zhhs.project.act.activity.controller;



import com.zhhs.common.utils.poi.ExcelUtil;
import com.zhhs.framework.aspectj.lang.annotation.Log;
import com.zhhs.framework.aspectj.lang.enums.BusinessType;
import com.zhhs.framework.web.controller.BaseController;
import com.zhhs.framework.web.domain.AjaxResult;
import com.zhhs.framework.web.page.TableDataInfo;
import com.zhhs.project.act.activity.domian.ActActivityUser;
import com.zhhs.project.act.activity.service.IActActivityUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 参与活动用户Controller
 *
 * @author peng
 * @date 2022-11-09
 */
@RestController
@RequestMapping("/wecom/activity/activityUser")
public class ActActivityUserController extends BaseController
{

    @Autowired
    private IActActivityUserService actActivityUserService;

    /**
     * 查询参与活动用户列表
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityuser:list')")
    @GetMapping("/list")
        public TableDataInfo list(ActActivityUser actActivityUser)
    {
        startPage();
        List<ActActivityUser> list = actActivityUserService.selectActActivityUserList(actActivityUser);
        return getDataTable(list);
    }

    /**
     * 导出参与活动用户列表
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityuser:export')")
    @Log(title = "参与活动用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(ActActivityUser actActivityUser)
    {
        List<ActActivityUser> list = actActivityUserService.selectActActivityUserList(actActivityUser);
        ExcelUtil<ActActivityUser> util = new ExcelUtil<ActActivityUser>(ActActivityUser.class);
        return util.exportExcel(list, "参与活动用户数据");
    }

    /**
     * 新增保存参与活动用户
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityuser:add')")
    @Log(title = "参与活动用户", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActActivityUser actActivityUser)
    {
        return toAjax(actActivityUserService.insertActActivityUser(actActivityUser));
    }


    /**
     * 修改保存参与活动用户
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityuser:edit')")
    @Log(title = "参与活动用户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActActivityUser actActivityUser)
    {
        return toAjax(actActivityUserService.updateActActivityUser(actActivityUser));
    }

    /**
     * 删除参与活动用户
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityuser:remove')")
    @Log(title = "参与活动用户", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actActivityUserService.deleteActActivityUserByIds(ids));
    }
}
